home *** CD-ROM | disk | FTP | other *** search
/ EuroCD 3 / EuroCD 3.iso / Programming / vbcc / machines / amiga68k / libsrc / stdio / fwrite.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-24  |  916 b   |  32 lines

  1. #include <stdio.h>
  2.  
  3. #include <proto/dos.h>
  4.  
  5. size_t fwrite(void *ptr,size_t size,size_t nmemb,FILE *f)
  6. {
  7.     size_t total=size*nmemb;char *p=ptr;long result;
  8.     if(!f||!total) return(0);
  9.     if((f->flags&(_WRITEABLE|_READ|_ERR|_EOF))!=_WRITEABLE) return(0);
  10.     f->flags|=_WRITE;
  11.     /*  einfache (ungepufferte) Implementation  */
  12.     fflush(f);
  13.     result=Write((BPTR)f->filehandle,p,total);
  14.     if(result==-1){f->flags|=_ERR;return(0);}
  15.     return(result/size);
  16.  
  17. /*    if(f->count){
  18.         if(total<=f->count){
  19.             memcpy(f->pointer,p,total);
  20.             f->pointer+=total;f->count-=total;
  21.             return(total);
  22.         }else{
  23.             memcpy(f->pointer,p,f->count);
  24.             total-=f->count;p+=f->count;
  25.             f->count=0;
  26.         }
  27.     }
  28.     result=Read(f->filehandle,p,total);
  29.     if(result==-1){f->flags|=_ERR;return((p-(char *)ptr)/size);}
  30.     return((p+total-(char *)ptr)/size);*/
  31. }
  32.